import sun.rmi.runtime.Log;

import java.util.Random;
import java.util.Scanner;

/**
 * 重写抽象系统：
 *      抽象出来了三个类：Login、Account、Menu
 *      分别管理：登录操作、用户信息、主菜单
 */
public class Login {

    public Scanner scanner = new Scanner(System.in);

    public Menu menu = new Menu();

    public Account account = new Account();

    public void start(){
        System.out.println(
                        "           1. 登陆\n" +
                        "           2. 注册\n" +
                        "           3. 退出\n" +
                        "        请选择：");

        String choose = scanner.next();

        switch (choose){
            case "1":
                //登录
                login();
                break;
            case "2":
                //注册
                register();
                break;
            case "3":
                //退出
                exit();
                break;
        }
    }

    public void login(){
        int random = new Random().nextInt(9000)+1000;
        System.out.println("验证码为："+random);

        System.out.println("请输入用户名：");
        String username = scanner.next();

        System.out.println("请输入密码：");
        String password = scanner.next();

        System.out.println("请输入验证码：");
        String randomStr = scanner.next();

        if(account.username.equals(username) && account.password.equals(password) && randomStr.equals(random+"")) {
            System.out.println("登录成功！");

            //进入主菜单
            menu.menu();
        }
    }

    public void register(){

    }

    public void exit(){

    }
}

class Test{

    public static void main(String[] args) {

        //创建对象
        Login login = new Login();

        login.start();
    }
}
